package club.emergency.wechat.department.search.consumer.controller;

import club.emergency.wechat.common.response.ResponseEntity;
import club.emergency.wechat.common.utils.JsonConvert;
import club.emergency.wechat.department.search.consumer.service.DepartmentSearchConsumer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Create with IntelliJ IDEA
 * Project Name: wechat
 * Package Name: club.emergency.wechat.department.search.consumer.controller
 * Date: 2019/3/23
 *
 * @author: 快乐的小菌菌
 * Description:
 */
@Api("企业查询接口")
@RestController
@RequestMapping("/department-search")
public class DepartmentSearchController {

    private DepartmentSearchConsumer departmentSearchConsumer;

    public DepartmentSearchController(DepartmentSearchConsumer departmentSearchConsumer) {
        this.departmentSearchConsumer = departmentSearchConsumer;
    }

    @ApiOperation("查询企业列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "匹配字段", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "pageNo", value = "当前页", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页数据大小", dataType = "string", paramType = "query")
    })
    @PostMapping("/flipList")
    public ResponseEntity flipList(
            @RequestParam(value = "code", required = false) String code,
            @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize
    ) {
        return new JsonConvert<ResponseEntity>().jsonDecode(departmentSearchConsumer.flipList(code, pageNo, pageSize), ResponseEntity.class);
    }
}
